package com.ruoyi.common.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.List;

/**
 * API请求
 */
@ApiModel(value = "动态查询请求")
public class APIRequest implements Serializable {

    /**
     * serialVersionUID:
     */
    private static final long serialVersionUID = -2647543499875978629L;

    /**
     * parameters:请求参数列表
     */
    @ApiModelProperty(required = false, value = "查询参数")
    private List<APIRequestParameter> parameters;
    /**
     * sorts:请求排序
     */
    @ApiModelProperty(required = false, value = "排序参数")
    private List<APIRequestSort> sorts;
    /**
     * requestPage:请求分页
     */
    @ApiModelProperty(required = false, value = "分页参数")
    private APIRequestPage requestPage;

    public String getParameter(String key) {
        if (parameters != null && parameters.size() > 0) {
            for (APIRequestParameter parameter : parameters) {
                if (null != parameter.getKey() && parameter.getKey().equals(key)) {
                    return parameter.getValue();
                }
            }
        }

        return null;
    }

    public List<APIRequestParameter> getParameters() {
        return parameters;
    }

    public void setParameters(List<APIRequestParameter> parameters) {
        this.parameters = parameters;
    }

    public List<APIRequestSort> getSorts() {
        return sorts;
    }

    public void setSorts(List<APIRequestSort> sorts) {
        this.sorts = sorts;
    }

    public APIRequestPage getRequestPage() {
        return requestPage;
    }

    public void setRequestPage(APIRequestPage requestPage) {
        this.requestPage = requestPage;
    }

}
